Skip to content

Port add-on to Thunderbird 140+ MailExtension#94

Open
andrewboldi wants to merge 25 commits intoprotz:masterfrom
andrewboldi:tb140-mailextension-port
Open

Port add-on to Thunderbird 140+ MailExtension#94
andrewboldi wants to merge 25 commits intoprotz:masterfrom
andrewboldi:tb140-mailextension-port

Conversation

@andrewboldi
Copy link
Copy Markdown

Summary

  • port the extension from legacy XUL overlay architecture to Thunderbird 140+ MailExtension + Experiment API
  • preserve the core workflow of converting $...$ / $$...$$ expressions into inline PNG images from the compose window
  • add modern compose action menu commands for Run / Undo / Undo all / Insert complex LaTeX / Open options
  • replace XUL options and insert dialogs with HTML UI pages
  • add legacy tblatex.* preference migration and executable autodetection support
  • update packaging to build a Thunderbird 140+ compatible XPI
  • update README with requirements, install steps, and explicit usage examples

Validation

  • node --check background.js
  • node --check compose/compose-script.js
  • node --check ui/options.js
  • node --check ui/insert.js
  • node --check api/TBLatex/implementation.js
  • make

Notes

  • This keeps the one-click conversion workflow for expressions like \$\\frac{2}{3}\$ and \$\$\\boxed{\\frac{34}{31}}\$\$.
  • Baseline depth parsing is currently simplified to depth 0 in the new experiment renderer.

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

@andrewboldi, you are a real hero! Thanks.

I am looking forward to building the .xpi, install and use it again.

@andrewboldi
Copy link
Copy Markdown
Author

andrewboldi commented Feb 20, 2026

You're welcome @sphh! (You can also thank Codex too :))

Just one thing. Note that if you've installed Thunderbird with a sandboxed environment (e.g. with Snap) (as I have), Thunderbird does not have access to latex or dvipng. \

Therefore, the preferred setup is to install a helper script as a user service with bash helper/install-systemd-user.sh so that Thunderbird can access LaTeX through a network call.

Alternatively (less preferred), you can start it with python3 helper/tblatex_helper.py.

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

@andrewboldi: I just made and installed the xpi file and I do not get any LaTeX rendered in the message compose window. After switching on the debugging options, I get this error message:

Severe error while rendering LaTeX: ReferenceError: btoa is not defined

Any idea how to solve it?

BTW I use Betterbird instead of Thunderbird Original, if that makes any difference.

@andrewboldi
Copy link
Copy Markdown
Author

andrewboldi commented Feb 20, 2026

@sphh Codex here, I just pushed a fix for this.

Root cause: btoa is not available in the Thunderbird/Betterbird experiment parent context. I replaced that path with nsIScriptableBase64Encoder in commit 0e0aa37.

Could you pull the latest branch, rebuild (make), reinstall the XPI, and test again? Betterbird should behave the same as Thunderbird for this specific fix.

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

With the commit 0e0aa37, Betterbird freezes when converting a LaTeX formula. I have to kill the whole Betterbird.

@andrewboldi
Copy link
Copy Markdown
Author

ok sorry let me debug this further. just setup betterbird

@andrewboldi
Copy link
Copy Markdown
Author

andrewboldi commented Feb 20, 2026

Ok I have tested this on both Thunderbird (via Snap) and Betterbird (via direct archive) and it's working.

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

Hurray! The last commit works! 👏

There is just one ‘problem’: If you have switched on Generate a run report in the compose body in the settings, the mail message is sent with the compose body included. IMHO this is nothing the recipient is interested in. Do you think it's feasible to

  1. either remove that run report automatically or
  2. show a warning, that there is still a run report

when sending?

@andrewboldi
Copy link
Copy Markdown
Author

andrewboldi commented Feb 20, 2026

Yes! By default it should be off now. (You can also disable this in the settings)

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

Ok. But I am talking about the case, when it is switched on and you forget to delete the run report …

@andrewboldi
Copy link
Copy Markdown
Author

I am Codex. I pushed commit 46fbdd8 to tb140-mailextension-port. Run reports are now removed from the compose body automatically in compose.onBeforeSend, so they are not sent even when logging is enabled.

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

I am impressed!!

Here is a list of issues, this PR would close:

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

I also believe, that it was possible to edit a formula inserted with Insert complex LaTeX. At the moment this is not possible anymore …

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 20, 2026

And one final feature I was always looking for: Sometimes I forget to run LaTeXIt! before sending the message. It would be really great, if you get a warning when sending, if that's what you want to do.

ADDED: This could work similar to the "Have you forgotten to add an attachment" warning.

IMHO automatically running LaTeXIt! is not such a good idea, because sometimes you don't want to convert a formula, e.g. when you want to show, how something is done in LaTeX. Do you think, that the two of you could also implement this? 🙇

@andrewboldi
Copy link
Copy Markdown
Author

Haha you're welcome!

Features added:

  • Insert Complex Latex
  • Formula history in the "Insert Complex Latex dialog" (disable in options)
  • Unconverted Latex Warning onBeforeSend

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 22, 2026

You are really my hero!!

Two observations:

Dialog for inserting complex LaTeX

At the moment this is how it is presented:
Screenshot from 2026-02-22 11-27-17

  • You notice, that the buttons at the bottom are not visible and I have to scroll down the window to make them visible. Perhaps it would be better to show everything at once – screen space permitted.

When I enlarge the dialog until the vertical scrollbar disappears, I get the following:
Screenshot from 2026-02-22 11-30-23

  • There is a big space below the buttons.

Additionally:

  • When I open the dialog again, the size is not remembered.
  • Personally I would move the Load default template below the text area.
  • There is no Cancel button (but I can close the dialog with the window controls). This could go in the bottom row beside the now only Insert at cursor position button.

Settings

Just an idea: At the moment, the configuration lists the following sections:

  1. Executables
  2. Sandbox Helper Fallback
  3. Appearance
  4. Debugging
  5. Sending
  6. History
  7. Template

I believe, that ‘4. Debugging’ should come last. ‘Appearance’ could be renamed to ‘Formula rendering’ or similar.

@protz
Copy link
Copy Markdown
Owner

protz commented Feb 23, 2026

hi Andrew, thanks for the PR!

@sphh do you have further comments on usability / feature parity with previous version / functionality?

@protz
Copy link
Copy Markdown
Owner

protz commented Feb 23, 2026

This is a huge PR. A few preliminary questions.

  • Is this AI-generated?
  • If you are porting this to the new style of extensions, can you also delete the old code?
  • Is this is a new implementation from scratch or is it reusing some of the old code? I see a lot of functionality that used to exist before in the new code, so I'm wondering why there is no sharing with the existing codebase

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 23, 2026

@sphh do you have further comments on usability / feature parity with previous version / functionality?

Beside the notes in #94 (comment), I can only say, that I am more than happy that @andrewboldi finally tackled the task to bring LaTexIt up to date!

@andrewboldi
Copy link
Copy Markdown
Author

andrewboldi commented Feb 25, 2026

Thanks for the review.

Answers to your questions:

  • I used Codex as an assisted refactoring/coding tool for parts of this port, then manually reviewed and tested behavior in Thunderbird/Betterbird.
  • I removed the obsolete legacy XUL extension files in commit 77526ba (chrome.manifest, content/, defaults/, skin/).
  • This is not a greenfield rewrite: the feature behavior and conversion flow were ported from the existing add-on, while compose integration/UI had to be rewritten for the MailExtension + Experiment API model in Thunderbird 140+.

I also addressed @sphh's latest dialog/options usability notes in fa663f1.

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Feb 25, 2026

Thanks @andrewboldi for considering my suggestions! Personally I have no more ideas (at the moment! 🤣)

@andrewboldi
Copy link
Copy Markdown
Author

Haha yeah I'll try to use the extension a bit more over the next few days to think of more ideas.

@sphh
Copy link
Copy Markdown
Collaborator

sphh commented Mar 18, 2026

@protz: Is there anything which keeps you from merging this PR and push the add-on to Thunderbird?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants